#ifndef THREADHANDLE_H
#define THREADHANDLE_H

#include <QThread>
#include <QString>

#include "utiladb.h"

typedef enum _ThreadResult {
    E_THREAD_RES_SUCCESS,
    E_THREAD_RES_FAIL,
    E_THREAD_RES_INTR,
    E_THREAD_ERR_MODE,
    E_THREAD_RES_OTHERS,
} ThreadResult;

class ThreadHandle : public QThread
{
    Q_OBJECT
public:
    ThreadHandle();
    void setCommand(QString cmd);
    QString getCmdResult();
    ThreadResult getResult();
    void setCmdSync();
    bool isRunning();

public slots:
    void slot_adbCmdSync(QString strSync);

signals:
    void signal_testReturn(int devCnt);
    void signal_testCmdSync(QString strSync);
    void signal_adbSyncEnd();

protected:
    void run();

private:
    QString m_command;
    QString m_cmdResult;
    ThreadResult m_result;
    UtilADB *m_adb;
    int m_adbCnt;
    bool m_bCmdSync = false;
    bool m_running = false;
};

#endif // THREADHANDLE_H
